package cn.piaoyi.web.action;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import cn.piaoyi.bean.Admin;
import cn.piaoyi.bean.Category;
import cn.piaoyi.bean.Goods;
import cn.piaoyi.comm.Constant;
import cn.piaoyi.comm.Util;
import cn.piaoyi.exception.PiaoyiException;
import cn.piaoyi.service.AdminService;
import cn.piaoyi.service.CategoryService;
import cn.piaoyi.service.CommentService;
import cn.piaoyi.service.DailyService;
import cn.piaoyi.service.GoodsService;
import cn.piaoyi.service.web.PageList;
import cn.piaoyi.service.web.Pages;
import cn.piaoyi.web.interceptor.UserSessionAware;
import cn.piaoyi.web.servlet.AdminSession;
import cn.piaoyi.web.servlet.UserSession;
import cn.piaoyi.web.ui.OptionsInt;
import cn.piaoyi.web.ui.OptionsLong;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.interceptor.SessionAware;

public class GoodsAction extends BaseAction implements UserSessionAware{
	private static final Log logger = LogFactory.getLog(GoodsAction.class);
	
	private GoodsService goodsService;
	private DailyService dailyService;
	private CategoryService categoryService;
	private CommentService commentService;

	public GoodsService getGoodsService() {
		return goodsService;
	}

	public void setGoodsService(GoodsService goodsService) {
		this.goodsService = goodsService;
	}
	
	public CategoryService getCategoryService() {
		return categoryService;
	}

	public void setCategoryService(CategoryService categoryService) {
		this.categoryService = categoryService;
	}
	
	public DailyService getDailyService() {
		return dailyService;
	}

	public void setDailyService(DailyService dailyService) {
		this.dailyService = dailyService;
	}
	
	public CommentService getCommentService() {
		return commentService;
	}

	public void setCommentService(CommentService commentService) {
		this.commentService = commentService;
	}
	
	private UserSession userSession;
	public UserSession getUserSession() {
		return userSession;
	}

	public void setUserSession(UserSession userSession) {
		this.userSession = userSession;
	}
	
	private Goods goods;
	private List commentList;
	private List dailyList;
	private List concertList;
	private List showList;
	private List dramaList;

	
	public Goods getGoods() {
		return goods;
	}

	public void setGoods(Goods goods) {
		this.goods = goods;
	}

	public List getCommentList() {
		return commentList;
	}

	public void setCommentList(List commentList) {
		this.commentList = commentList;
	}

	public List getDailyList() {
		return dailyList;
	}

	public void setDailyList(List dailyList) {
		this.dailyList = dailyList;
	}

	public List getConcertList() {
		return concertList;
	}

	public void setConcertList(List concertList) {
		this.concertList = concertList;
	}

	public List getShowList() {
		return showList;
	}

	public void setShowList(List showList) {
		this.showList = showList;
	}

	public List getDramaList() {
		return dramaList;
	}

	public void setDramaList(List dramaList) {
		this.dramaList = dramaList;
	}	
	
	private long id;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String execute() {
		try {
			return this.executeMethod(this.getAction());
		} catch (Exception e) {
			logger.error(e);
			return INPUT;
		}
	}

	/**
	 * 初始页
	 */
	public String index(){
		this.goods = this.getGoodsService().findGoodsById(this.id);
		this.commentList = this.getCommentService().findComments(this.id, -1, 1, "id", 1, 0, 10);
		this.dailyList = this.getDailyService().findDailys(this.id, "id", 0);
		
		this.concertList = this.getGoodsService().findGoodses(userSession.getCityId(),Constant.CATEGORY_CONCERT, "", 1, -1, "id", 1, 0, 6);
		this.showList = this.getGoodsService().findGoodses(userSession.getCityId(),Constant.CATEGORY_SHOW, "", 1, -1, "id", 1, 0, 6);
		this.dramaList = this.getGoodsService().findGoodses(userSession.getCityId(),Constant.CATEGORY_DRAMA, "", 1, -1, "id", 1, 0, 6);
		
		return SUCCESS;
	}


}
